/**
 * 
 */
package it.polimi.leo.mw;

import it.polimi.leo.mw.IMiddleWare.IMiddlewareMessageKind;

import java.util.List;

/**
 * @author Lev
 *
 */
public interface IMiddleWareNode {

    /**
     * Global ID with address information
     */
    String getID();

    /**
     * to all members of group you are joined
     */
    void sendMsg(IMiddlewareMessage msg);

    /**
     * to one members of group you are joined
     */
    void sendMsgTo(IMiddlewareMessage msg, IMiddleWareNode receiver);

    /**
     * msg for group you have joined before
     */
    IMiddlewareMessage receiveMsg();

    /**
     * only special kind
     */
    //IMiddlewareMessage receiveMsg(IMiddlewareMessageKind kind);
    boolean hasMsg();
    IMiddleWareMsgHandler setMsgHandler(IMiddleWareMsgHandler handler);
    /*
     * Only from special sender
     */
    //IMiddlewareMessage receiveMsg(IMiddleWareNode sender);

    /**
     * Create group if it not exist, leave previous group
     */
    IMiddleWareNode joinGroup(IMiddleWareGroup group) throws JoinGroupException;
    
    /**
     *
     */
    IMiddleWareNode leaveGroup() throws JoinGroupException;
    
    /**
     * get all members of the group
     */
    List<IMiddleWareNode> getGroupListners();

    IMiddleWareGroup getJoinedGroup();

    Object getUpdatedState();

    //void setMsgHandler (IMiddleWareMsgHandler handler);
}
